package com.hunter.hmi;

import com.hunter.listener.TextFieldActionListenter;
import com.hunter.listener.TextFieldKeyListenter;

import javax.swing.*;



public class Hmi extends JFrame{
    /**
     *@Project:iwms
     *@Description: 界面
     *@Author: Mr.Hunter
     *@Date:2022/5/14/12:54
     */
    JFrame jf = new JFrame("订单号界面");
    private int x;
    private int y;
    private String nx;
    private String ny;
    private JLabel OrderJLabel;
    private JLabel AbscissaJLabel;
    private JLabel OrdinateJLabel;
    TextFieldActionListenter listenter;
    TextFieldKeyListenter li;
    TransparentHmi use = new TransparentHmi();
    public JTextField AbscissaJTextField;
    public JTextField OrdinateJTextField;
    private JTextField OrderTextField;
    private JButton DemandJButton;
    private JButton TranscribeJButton;
    final int WIDTH = 300;
    final int HEIGHT = 150;


    public void init() {
        x = use.getX();
        y = use.getY();

        jf.setBounds((ScreenWidthHeight.getScreenWidth() - WIDTH) / 2, (ScreenWidthHeight.getScreenHeight() - 1080) / 2, WIDTH, HEIGHT);
        jf.setResizable(false);
        jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        /**
         * @program com.hunter.hmi.Hmi
         * @Description 设置竖直箱
         * @return void
         * @Author Mr.Hunter
         * @Date 2022/5/13 22:22
         */
        Box vBox = Box.createVerticalBox();

        /**
         * @program com.hunter.hmi.Hmi
         * @Description 组装坐标并添加按钮
         * @return void
         * @Author Mr.Hunter
         * @Date 2022/5/13 22:26
         */
        Box acrBox = Box.createHorizontalBox();
        JLabel AbscissaJLabel = new JLabel("横坐标:");
        AbscissaJTextField = new JTextField(String.valueOf(x));
        JLabel OrdinateJLabel = new JLabel("纵坐标:");
        OrdinateJTextField = new JTextField(String.valueOf(y));
        listenter = new TextFieldActionListenter(AbscissaJTextField,OrdinateJTextField);

        acrBox.add(AbscissaJLabel);
        acrBox.add(AbscissaJTextField);
        acrBox.add(Box.createHorizontalStrut(10));
        acrBox.add(OrdinateJLabel);
        acrBox.add(OrdinateJTextField);

        /**
         * @program com.hunter.hmi.Hmi
         * @Description 添加输入框组件
         * @return void
         * @Author Mr.Hunter
         * @Date 2022/5/13 22:27
         */
        Box uBox = Box.createHorizontalBox();
        JLabel Orderlabel = new JLabel("订单号:");
        OrderTextField = new JTextField(15);
        li = new TextFieldKeyListenter(OrderTextField);
        OrderTextField.addActionListener(listenter);

        uBox.add(Orderlabel);
        uBox.add(OrderTextField);

        /**
         * @program com.hunter.hmi.Hmi
         * @Description 添加按钮
         * @return void
         * @Author Mr.Hunter
         * @Date 2022/5/13 22:28
         */
        Box binBox = Box.createHorizontalBox();

        DemandJButton = new JButton("查询");
        TranscribeJButton = new JButton("录制");

        binBox.add(Box.createHorizontalStrut(45));
        binBox.add(DemandJButton);
        binBox.add(Box.createHorizontalStrut(50));
        binBox.add(TranscribeJButton);

        /**
         * @program com.hunter.hmi.Hmi
         * @Description 竖直组装
         * @return void
         * @Author Mr.Hunter
         * @Date 2022/5/13 22:28
         */
        vBox.add(Box.createVerticalStrut(18));
        vBox.add(acrBox);
        vBox.add(Box.createVerticalStrut(5));
        vBox.add(uBox);
        vBox.add(Box.createVerticalStrut(5));
        vBox.add(binBox);
        /**
         * @program com.hunter.hmi.Hmi
         * @Description JavaSwing
         * @return void
         * @Author Mr.Hunter
         * @Date 2022/5/13 22:29
         */
        jf.setContentPane(vBox);
        jf.setVisible(true);
        jf.setAlwaysOnTop(true);

    }
    public void TextField(){

    }



}
